subroutine r2abij_t2abim_fmj(r2, t2, fmi, icore, fact)
!
use mod_size
use mod_orbit
use mod_ioff
use mod_iop 
implicit none
!
real*8, intent(in) :: fact
real*4, intent(in) :: r2(*) 
real*4, intent(in) :: fmi(*)
!
real*4, intent(inout) :: t2(*), icore(*)
!
integer :: i, j, a, b, nsize
integer :: i0, i1, i2, i3
integer, external :: idsymsoc
real*8, external :: dnrm2
!this is to do r2(ab,ij) = r2(abij) - P(ij)t2(ab,im)*f(mj)
i0 = 1
i1 = i0 + nvvoo*isd
i2 = i1 + nvvoo*isd
i3 = i2 + nvvoo*isd
!
!====AAAA
call iexpso(t2(ioi3(1)), icore(i0), vrta, vrta, 0, 0, popa, popa, 0, 1, 1)
call VpqrmVms_to_Vpqrs(icore(i0), fmi(ifoo(1)), 1, 1, popa, &
             vrta, vrta, 0, popa, popa, icore(i1), 1, fact, 0.d0, 0)
call iassymso(icore(i1), icore(i0), 1, vrta, vrta, popa, popa, 0)
call axpyso(nioi31, 1.d0, icore(i0), 1, r2(ioi3(1)), 1)
!====BBBB
call iexpso(t2(ioi3(3)), icore(i0), vrtb, vrtb, 0, 0, popb, popb, 0, 1, 1)
call VpqrmVms_to_Vpqrs(icore(i0), fmi(ifoo(2)), 1, 1, popb, &
             vrtb, vrtb, 0, popb, popb, icore(i1), 1, fact, 0.d0, 0)
call iassymso(icore(i1), icore(i0), 1, vrtb, vrtb, popb, popb, 0)
call axpyso(nioi33, 1.d0, icore(i0), 1, r2(ioi3(3)), 1)
!====ABAB
! T2(Ab,Im)*F(mj)-T2(Ab,jM)*FMI
!=T2(Ab,Im)*F(mj)+T2(Ab,Mj)*FMI
nsize = idsymsoc(1, vrta, vrtb, 1, popa, popb, 1) 
call VpqrmVms_to_Vpqrs(t2(ioi3(2)), fmi(ifoo(2)), 1, 1, popb, &
             vrta, vrtb, 1, popa, popb, r2(ioi3(2)), 1, fact, 1.d0, 1)
!
call isymtrso(t2(ioi3(2)), icore(i0), vrta, vrtb, 1, 0, popa, popb, 1, 1, 1) 
call VpqrmVms_to_Vpqrs(icore(i0), fmi(ifoo(1)), 1, 1, popa, &
             vrta, vrtb, 1, popb, popa, icore(i1), 1, fact, 0.d0, 1)
call isymtrso(icore(i1), icore(i0), vrta, vrtb, 1, 0, popb, popa, 1, 1, 1) 
call axpyso(nioi32, 1.d0, icore(i0), 1, r2(ioi3(2)), 1)
!
return
end
